{{include file="public/header" /}}

<!-- right content start  -->
<div class="content-right">
    <div class="content">
        <!-- nav start -->
        {{include file="pluginsadmin/nav" /}}
        <!-- nav end -->

        <!-- operation start -->
        {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
            <div class="am-g am-margin-bottom-sm am-margin-top-sm">
                <a href="{{:MyUrl('admin/pluginsadmin/saveinfo')}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus"> {{:MyLang('add_title')}}</a>
            </div>
        {{/if}}
        <!-- operation end -->

        <div class="plugins-data-list am-nbfc">
            {{if !empty($data_list['db_data']) or !empty($data_list['dir_data'])}}
                <div class="am-input-group am-input-group-sm plugins-search">
                    <input type="text" class="am-form-field am-radius" placeholder="{{:MyLang('pluginsadmin.base_search_input_placeholder')}}" />
                    <span class="am-input-group-btn">
                        <button class="am-btn am-btn-default am-radius am-icon-search" type="button"> {{:MyLang('search_title')}}</button>
                    </span>
                </div>

                <!-- 操作提示 -->
                <div class="am-alert am-radius">
                    <p>{{:MyLang('pluginsadmin.base_top_tips_one')}}</p>
                    <p>
                        <span>{{:MyLang('pluginsadmin.base_top_tips_two')}}</span>
                        <a href="javascript:;" class="am-margin-left am-icon-cog submit-move-setup-open"> {{:MyLang('pluginsadmin.base_open_setup_title')}}</a>
                        <a href="javascript:;" class="am-margin-left am-icon-check submit-move-setup-save am-hide"> {{:MyLang('save_title')}}</a>
                        <a href="javascript:;" class="am-margin-left-sm am-icon-close submit-move-setup-cancel am-hide"> {{:MyLang('cancel_title')}}</a>
                    </p>
                    {{if empty($site_store_info) or empty($site_store_info['user'])}}
                        <p>
                            <span>{{:MyLang('store_bind_accounts_tips')}}</span>
                            <button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs am-margin-left-xs am-icon-gg store-accounts-event"> {{:MyLang('store_bind_accounts_name')}}</button>
                        </p>
                    {{/if}}
                </div>

                {{if !empty($data_list['db_data'])}}
                    <!-- 插件分类 -->
                    <div class="plugins-category-nav am-padding-vertical-xs">
                        <strong>{{:MyLang('pluginsadmin.plugins_category_title')}}</strong>
                        <button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs am-margin-left-sm">{{:MyLang('all_title')}}</button>
                        {{if !empty($plugins_categosy_list)}}
                            {{foreach $plugins_categosy_list as $cv}}
                                <button type="button" class="am-btn am-btn-default am-radius am-btn-xs am-margin-left-sm" data-value="{{$cv.id}}">{{$cv.name}}</button>
                            {{/foreach}}
                        {{/if}}
                        <a href="javascript:;" class="am-fr am-margin-top-xs am-icon-list-ul submit-popup" data-url="{{:MyUrl('admin/pluginscategory/index')}}" data-full="1" data-full-max="1" data-class="plugins-category-save-popup"> {{:MyLang('pluginsadmin.plugins_category_admin_title')}}</a>
                    </div>

                    <!-- 已安装 -->
                    <ul class="already-install am-nbfc" data-setup-save-url="{{:MyUrl('admin/pluginsadmin/setupsave')}}">
                        {{foreach $data_list['db_data'] as $v}}
                            {{if isset($v['is_install']) and $v['is_install'] eq 1}}
                                <li class="plugins-category-{{$v.plugins_category_id}}" data-id="{{$v.id}}" data-plugins="{{$v.plugins}}">
                                    <div class="item {{if $v['is_enable'] eq 0}}am-active{{/if}}" id="data-list-{{$v.plugins}}">
                                        <img src="{{$v.logo}}" class="icon" />
                                        <div class="base">
                                            <h3 class="name">{{$v.name}}</h3>
                                            <p>{{:MyLang('pluginsadmin.data_list_author_title')}}：{{$v.author}}</p>
                                            {{if empty($site_store_info) or empty($site_store_info['vip']) or !isset($site_store_info['vip']['status']) or $site_store_info['vip']['status'] eq 0}}
                                                <p>{{:MyLang('pluginsadmin.data_list_author_url_title')}}：<a href="{{$v.author_url}}" target="_blank">{{$v.author_url}}</a></p>
                                            {{/if}}
                                            <p>{{:MyLang('pluginsadmin.data_list_version_title')}}：{{$v.version}}</p>
                                        </div>
                                        <div class="desc">{{$v.desc}}</div>
                                        <div class="operation">
                                            {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
                                                <a href="{{:MyUrl('admin/pluginsadmin/saveinfo', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-edit" title="{{:MyLang('edit_title')}}"></a>
                                                <a href="{{:MyUrl('admin/pluginsadmin/download', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-download" title="{{:MyLang('download_title')}}"></a>
                                                <button class="am-btn am-btn-default am-btn-xs am-radius am-icon-cloud-upload submit-popup" data-url="{{:MyUrl('admin/pluginsadmin/storeuploadinfo', ['id'=>$v['plugins']])}}" title="{{:MyLang('upload_title')}}"></button>
                                            {{/if}}

                                            <a href="javascript:;" data-set-url="{{:PluginsAdminUrl($v['plugins'], 'admin', 'index')}}" data-name="{{$v.name}}" data-key="plugins-{{$v.plugins}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-gear plugins-set-event" title="{{:MyLang('setup_title')}}"></a>
                                            
                                            <button class="am-btn am-btn-default am-btn-xs am-radius am-icon-circle-o submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/uninstall')}}" data-id="{{$v.plugins}}" data-view="reload" data-msg="{{:MyLang('pluginsadmin.uninstall_confirm_tips')}}" title="{{:MyLang('uninstall_title')}}"></button>

                                            <a href="javascript:;" class="am-btn am-btn-default am-btn-xs am-icon-check submit-state {{if $v['is_enable'] eq 1}}am-success{{/if}}" data-url="{{:MyUrl('admin/pluginsadmin/statusupdate')}}" data-id="{{$v.plugins}}" data-state="{{$v['is_enable']}}" data-is-update-status="1" title="{{:MyLang('status_title')}}"></a>

                                            {{if isset($v['is_home']) and $v['is_home'] eq true}}
                                                <a href="{{:PluginsHomeUrl($v['plugins'], 'index', 'index')}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-home" title="{{:MyLang('home_title')}}" target="_blank"></a>
                                            {{/if}}

                                            <button type="button" class="am-btn am-btn-secondary am-btn-xs am-radius am-icon-arrows submit-move am-hide" title="{{:MyLang('sort_title')}}"></button>

                                            {{if !empty($upgrade_info) and isset($upgrade_info[$v['plugins']])}}
                                                {{if isset($upgrade_info[$v['plugins']]['version_new']) and version_compare($upgrade_info[$v['plugins']]['version_new'], $v['version'], '>')}}
                                                    <button class="am-btn am-btn-danger am-btn-xs am-radius am-icon-refresh package-upgrade-event" title="{{:MyLang('update_title')}}" data-type="plugins" data-name="{{$v.name}}" data-value="{{$v.plugins}}" data-json="{{:urlencode(json_encode($upgrade_info[$v['plugins']]))}}"></button>
                                                {{/if}}
                                                {{if !empty($upgrade_info[$v['plugins']]['version_main']) and $upgrade_info[$v['plugins']]['version_main'] neq $v['version']}}
                                                    <span class="am-fr am-text-danger am-margin-top-sm">v{{$upgrade_info[$v['plugins']]['version_main']}}</span>
                                                {{/if}}
                                            {{/if}}
                                        </div>
                                        <div class="plugins-right-top-container am-hide">
                                            {{if !empty($left_menu)}}
                                                <div class="am-inline-block chosen-select-item">
                                                    <select class="am-radius chosen-select" name="plugins_menu_control" data-placeholder="{{:MyLang('pluginsadmin.plugins_menu_control_title')}}">
                                                        <option value="">{{:MyLang('pluginsadmin.plugins_menu_control_title')}}</option>
                                                        {{foreach $left_menu as $nv}}
                                                            <option value="{{$nv.control}}" {{if isset($v['plugins_menu_control']) and $v['plugins_menu_control'] eq strtolower($nv['control'])}}selected{{/if}}>{{$nv.name}}</option>
                                                        {{/foreach}}
                                                    </select>
                                                </div>
                                            {{/if}}
                                            {{if !empty($plugins_categosy_list)}}
                                                <div class="am-inline-block chosen-select-item">
                                                    <select class="am-radius chosen-select" name="plugins_category_id" data-placeholder="{{:MyLang('pluginsadmin.plugins_category_title')}}">
                                                        <option value="">{{:MyLang('pluginsadmin.plugins_category_title')}}</option>
                                                        {{foreach $plugins_categosy_list as $cv}}
                                                            <option value="{{$cv.id}}" {{if isset($v['plugins_category_id']) and $cv['id'] eq $v['plugins_category_id']}}selected{{/if}}>{{$cv.name}}</option>
                                                        {{/foreach}}
                                                    </select>
                                                </div>
                                            {{/if}}
                                        </div>
                                    </div>
                                </li>
                            {{/if}}
                        {{/foreach}}
                    </ul>

                    <!-- 搜索无数据展示 -->
                    <div class="not-data-tips am-hide">
                        {{include file="public/not_data" /}}
                    </div>
                {{/if}}

                {{if !empty($data_list['dir_data'])}}
                    <!-- 未安装 -->
                    <div class="am-text-center am-margin-top-lg am-margin-bottom-xs middle-divider">
                        <strong>
                            <i class="am-icon-angle-double-down"></i>
                            <span class="am-text-lg am-margin-horizontal-xs">{{:MyLang('pluginsadmin.not_install_divide_title')}}</span>
                            <i class="am-icon-angle-double-down"></i>
                        </strong>
                        <hr data-am-widget="divider" class="am-divider am-divider-dashed am-margin-top-0" />
                    </div>
                    <ul class="am-nbfc" data-setup-save-url="{{:MyUrl('admin/pluginsadmin/sortsave')}}">
                        {{foreach $data_list['dir_data'] as $v}}
                            {{if !isset($v['is_install']) or $v['is_install'] eq 0}}
                                <li data-id="{{$v.id}}" data-plugins="{{$v.plugins}}">
                                    <div class="item am-active" id="data-list-{{$v.plugins}}">
                                        <img src="{{$v.logo}}" class="icon" />
                                        <div class="base">
                                            <h3 class="name">{{$v.name}}</h3>
                                            <p>{{:MyLang('pluginsadmin.data_list_author_title')}}：{{$v.author}}</p>
                                            {{if empty($site_store_info) or empty($site_store_info['vip']) or !isset($site_store_info['vip']['status']) or $site_store_info['vip']['status'] eq 0}}
                                                <p>{{:MyLang('pluginsadmin.data_list_author_url_title')}}：<a href="{{$v.author_url}}" target="_blank">{{$v.author_url}}</a></p>
                                            {{/if}}
                                            <p>{{:MyLang('pluginsadmin.data_list_version_title')}}：{{$v.version}}</p>
                                        </div>
                                        <div class="desc">{{$v.desc}}</div>
                                        <div class="operation">
                                            {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
                                                <a href="{{:MyUrl('admin/pluginsadmin/saveinfo', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-edit" title="{{:MyLang('edit_title')}}"></a>
                                                <a href="{{:MyUrl('admin/pluginsadmin/download', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-download" title="{{:MyLang('download_title')}}"></a>
                                                <button class="am-btn am-btn-default am-btn-xs am-radius am-icon-cloud-upload submit-popup" data-url="{{:MyUrl('admin/pluginsadmin/storeuploadinfo', ['id'=>$v['plugins']])}}" title="{{:MyLang('upload_title')}}"></button>
                                            {{/if}}

                                            <button class="am-btn am-btn-default am-btn-xs am-radius am-icon-remove submit-delete-modal" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="{{$v.plugins}}" title="{{:MyLang('delete_title')}}"></button>

                                            <button class="am-btn am-btn-default am-btn-xs am-radius am-icon-cubes submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/install')}}" data-id="{{$v.plugins}}" data-view="reload" data-msg="{{:MyLang('install_confirm_tips')}}" title="{{:MyLang('install_title')}}"></button>
                                        </div>
                                    </div>
                                </li>
                            {{/if}}
                        {{/foreach}}
                    </ul>

                    <!-- 删除弹层 -->
                    <div class="am-modal am-modal-no-btn" tabindex="-1" id="plugins-delete-modal">
                        <div class="am-modal-dialog am-radius am-nbfc">
                            <div class="am-modal-hd">
                                <a href="javascript: void(0)" class="am-close" data-am-modal-close>&times;</a>
                            </div>
                            <div class="am-modal-bd am-margin-top-sm">
                                <div class="am-alert  am-text-left" data-am-alert>
                                    <p>{{:MyLang('pluginsadmin.delete_plugins_text')}}<span class="am-text-warning">{{:MyLang('pluginsadmin.delete_plugins_text_tips')}}</span></p>
                                    <p>{{:MyLang('pluginsadmin.delete_plugins_data_text')}}<span class="am-text-warning">{{:MyLang('pluginsadmin.delete_plugins_data_text_tips')}}</span></p>
                                </div>
                                <p class="am-text-danger am-margin-top">{{:MyLang('pluginsadmin.delete_plugins_ps_tips')}}</p>
                                <div class="am-margin-top-sm">
                                    <button class="am-btn am-btn-danger am-btn-xs am-radius am-icon-circle-o submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="0" data-value="1" data-view="reload" data-msg="{{:MyLang('delete_confirm_tips')}}"> {{:MyLang('pluginsadmin.delete_plugins_data_button_name')}}</button>
                                    <button class="am-btn am-btn-warning am-btn-xs am-radius am-icon-remove submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="0" data-value="0" data-view="reload" data-msg="{{:MyLang('delete_confirm_tips')}}"> {{:MyLang('pluginsadmin.delete_plugins_button_name')}}</button>

                                    <button class="am-btn am-btn-success am-btn-xs am-radius am-icon-reply" data-am-modal-close> {{:MyLang('pluginsadmin.cancel_delete_plugins_button_name')}}</button>
                                </div>
                            </div>
                        </div>
                    </div>
                {{/if}}

                {{if $is_system_show_base eq 1}}
                    <div class="am-padding-vertical-xl am-text-center">
                        <a href="{{$store_url}}" target="_blank" class="am-margin-left-xs">{{:MyLang('pluginsadmin.more_plugins_store_to_text')}}</a>
                    </div>
                {{/if}}
            {{else /}}
                <div class="table-no">
                    <i class="am-icon-skyatlas am-icon-lg"></i>
                    <p class="am-margin-top-sm">{{:MyLang('plugins_no_data_tips')}}</p>
                    {{if $is_system_show_base eq 1}}
                        <div class="am-margin-top-xl">
                            <a href="{{$store_url}}" target="_blank" class="am-margin-left-xs">{{:MyLang('pluginsadmin.no_data_store_to_text')}}</a>
                        </div>
                    {{/if}}
                </div>
            {{/if}}
        </div>
    </div>
</div>
<!-- right content end  -->

<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->